<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .ad{
            position: relative;
            width: 300px;
            height: 400px;
            margin: 100px auto;
        }
        .ad p{
            position: absolute;
            top: 395px;
            right: 80px;
            font-size: 15px;
            color: black;
        }
        img{
            width: 300px;
            height: 400px;
        }
    </style>
</head>
<body>
    <div class="ad">
        <img src="img/tp2.jpg" class="tp2_img">
        <p></p>
    </div>
    <script>
        var ad=document.querySelector('.ad');
        var tip=document.querySelector('p');
        var time=3;
        fn();
        var timer=setInterval(fn,1000);
        function fn(){
            if(time==0){
                ad.style.diaplay='none';
                clearInterval(timer);
            }
            tip.innerHTML=time+'秒后自动关闭广告';
            time--;
        }
    </script>
</body>
</html>